int max_renum(int n)
{
    if (n >= 1000 || n < 1)    return -1;
    int a = n % 10, b = n / 10 % 10, c = n / 100 % 10;
    int sum = a + b + c;
    int mx = (a > b) ? a : b;
    mx = (mx > c) ? mx : c;
    int mn = (a < b) ? a : b;
    mn = (mn < c) ? mn : c;
    return mx * 100 + (sum - mx - mn) * 10 + mn;
}